import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:nav_router/nav_router.dart';
import 'package:ncov_2019/config/config.dart';
import 'package:ncov_2019/config/const.dart';
import 'package:ncov_2019/pages/root/root_page.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'http/api_service.dart';


class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    saveUUID();
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: title,
      navigatorKey: navGK,
      theme: ThemeData(
        indicatorColor: appBarColor,
        scaffoldBackgroundColor: bgColor,
        hintColor: Colors.grey.withOpacity(0.3),
        splashColor: Colors.transparent,
        canvasColor: Colors.transparent,
      ),
      home: new RootPage(),
    );
  }
}
saveUUID() async {
  SharedPreferences sp = await SharedPreferences.getInstance();
  // sp.setStringList("cookies", cookie);
  String uuid = sp.getString("uuid");
  if(uuid==null){
    ApiService().getUUID((String _uuid) {
      if (_uuid != null) {
        sp.setString("uuid", _uuid);
        print(_uuid);
      }
    });
  }else{
    print(uuid);
  }
}
